#include "../stdafx.h"
#include "Color.h"
#include <iostream>
namespace Model{


	void Color::setTreasureStack(vector<Treasure*> ts)
	{
		this->treasureStack=ts;
	}
	/**
	 * @param t the treasure to add at the top of the treasureStack
	 */
	void Color::pushTreasure(Treasure* t)
	{
		this->treasureStack.push_back(t);
	}
	/**
	 * remove the treasure at the top of the stack
	 */
	void Color::popTreasure()
	{
		this->treasureStack.pop_back();
	}
/*	Treasure* Color::getNextTreasure()
	{
		//return *this->treasureStack.end().base();
		return NULL;
	}*/
	bool Color::hasTreasure()
	{
		return this->treasureStack.empty();
	}
	Color::Color(string name)
	{
		this->name=name;
	}
	/**
	 * @return the current tile of the color
	 */
	Tile* Color::getCurrentTile()
	{
		return this->currentTile;
	}
	/**
	 * set the current tile
	 */
	void Color::setCurrentTile(Tile* t)
	{
		this->currentTile=t;
		cout<<"je change currentTile"<<endl;
	}
	/**
	 * Allow the color to go up one tile in the grid
	 */
	void Color::goUp()
	{
		if(currentTile->canGoUp() && currentTile->upNeighbor()!=NULL){
			currentTile=currentTile->upNeighbor();
		}
	}
	/**
	 * Allow the color to go down one tile in the grid
	 */
	void Color::goDown()
	{
		if(currentTile->canGoDown() && currentTile->downNeighbor()!=NULL){
			currentTile=currentTile->downNeighbor();
		}
	}
	/**
	 * Allow the color to go left one tile in the grid
	 */
	void Color::goLeft()
	{
		if(currentTile->canGoLeft() && currentTile->leftNeighbor()!=NULL){
			currentTile=currentTile->leftNeighbor();
		}
	}
	/**
	 * Allow the color to go right one tile in the grid
	 */
	void Color::goRight()
	{
		if(currentTile->canGoRight() && currentTile->rightNeighbor()!=NULL){
			currentTile=currentTile->rightNeighbor();
		}
	}

	Color::~Color(void)
	{
		for (unsigned int i = 0; i < this->treasureStack.size(); ++i) {
			delete this->treasureStack[i];
		}
	}

	string Color::getName()
	{
		return name;
	}
	/**
	 * return the name of the treasure at the top of the treasureStack
	 */
	string Color::getTopTreasure()
	{
		return (*(this->treasureStack.begin()))->getName();

	}
}
